package P05多线程锁.P03可重入锁;

public class P01_SyncDemo {
    public static void main(String[] args) {
        Object o = new Object();
        new Thread(() ->{
            synchronized (o) {
                System.out.println(Thread.currentThread().getName() + " 外层");
                synchronized (o) {
                    System.out.println(Thread.currentThread().getName() + " 中层");
                    synchronized (o) {
                        System.out.println(Thread.currentThread().getName() + " 内层");
                    }
                }
            }
        },"AA").start();

//        new P01_SyncLockDemo().add(); // StackOverflowError
    }

    public synchronized void add() {
        add();
    }
}
